package com.wg.springbootservlet.one;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description:
 * @Author WuGang
 * @Date 2021/10/20 19:47
 * @Version 1.0
 */
@WebServlet(urlPatterns = "/myservlet")  //相当于以前的web.xml里面的标签  但是这里是声明是一个servlet  但是本身没有注入到spring中 在入口类扫描
public class MyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//    往相应体里面放点东西
        resp.getWriter().println("my  springboot servlet");
        resp.getWriter().flush();
        resp.getWriter().close();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        让他直接调doget
        doGet(req, resp);
    }
}
